package com.company.thread;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2020/10/23 14:17
 */
public class MyThread9 {

    public static void main(String[] args) {
        Thread t  = new Thread(new OtherRunnableObj());
        t.setName("我是t");
        t.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("main 打断线程的睡眠");
        t.interrupt();   //打断线程 “我是t” 的睡眠状态

        System.out.println("main exit");

    }



}

class OtherRunnableObj implements Runnable {
    @Override
    public void run() {
        try {
            System.out.println(Thread.currentThread().getName()+"进入睡眠");
            Thread.sleep(30000);
        } catch (InterruptedException e) {
            System.out.println(Thread.currentThread().getName()+"退出睡眠");
            //e.printStackTrace();
        }
    }
}


